package com.softer.wxzj.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.common.util.StringUtils;
import com.softer.wxzj.entity.PayInTransitAudit;
import com.softer.wxzj.entity.ProjectInTransitAudit;
import com.softer.wxzj.mapper.InTransitAuditMapper;
import com.softer.wxzj.service.InTransitAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Gong Zhiyang
 * @date 2019/8/13
 */
@Service
public class InTransitAuditServiceImpl implements InTransitAuditService {
    @Autowired
    private InTransitAuditMapper inTransitAuditMapper;

    /**
     * 获取项目在途审核列表
     *
     * @param page                  分页实体
     * @param projectInTransitAudit 查询实体
     * @return 列表
     */
    @Override
    public PageInfo<ProjectInTransitAudit> getProjectInTransitAudit(Page page, ProjectInTransitAudit projectInTransitAudit) {
        List<ProjectInTransitAudit> list;
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        if (StringUtils.isNotEmpty(projectInTransitAudit.getFuzzy())) {
            //模糊查询
            list = inTransitAuditMapper.fuzzyProjectInTransitAudit(projectInTransitAudit.getFuzzy());
        } else {
            //精确查询
            list = inTransitAuditMapper.getProjectInTransitAudit(projectInTransitAudit);
        }
        PageInfo<ProjectInTransitAudit> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 获取拨款申请在途审核列表
     *
     * @param page              分页实体
     * @param payInTransitAudit 查询实体
     * @return 列表
     */
    @Override
    public PageInfo<PayInTransitAudit> getPayInTransitAudit(Page page, PayInTransitAudit payInTransitAudit) {
        List<PayInTransitAudit> list;
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        if (StringUtils.isNotEmpty(payInTransitAudit.getFuzzy())) {
            //模糊查询
            list = inTransitAuditMapper.fuzzyPayInTransitAudit(payInTransitAudit.getFuzzy());
        } else {
            //精确查询
            list = inTransitAuditMapper.getPayInTransitAudit(payInTransitAudit);
        }
        PageInfo<PayInTransitAudit> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
